﻿namespace BLL.Security
{
    /// <summary>
    /// Defines interface for authentication and authorization within the system.
    /// </summary>
    public interface ISecurityService
    {
        /// <summary>
        /// Authenticates user in the system.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">User password.</param>
        /// <returns>Authentication result for provided credentials.</returns>
        Models.Users.AuthenticationStatus AuthenticateUser(string userName, string password);

        /// <summary>
        /// Authenticates administrator in the system.
        /// </summary>
        /// <param name="userName">Administrator user name.</param>
        /// <param name="password">Administrator password.</param>
        /// <returns>Authentication result for provided credentials.</returns>
        Models.Administrators.AuthenticationStatus AuthenticateAdministrator(string userName, string password);

        /// <summary>
        /// Verifies system account credentials.
        /// </summary>
        /// <param name="userName">System user name.</param>
        /// <param name="password">Sytem user password.</param>
        /// <returns>true if credentials are correct; false otherwise.</returns>
        bool AuthenticateSystemAccount(string userName, string password);

        /// <summary>
        /// Authorizes the specified user in the system.
        /// </summary>
        /// <param name="userName">User name of the account to authorize.</param>
        /// <param name="accountType">User type to authrize account against.</param>
        /// <param name="assignedRoles">
        /// Receives roles assigned to the specified account. Will be left unchanged for system and
        /// administrative accounts.
        /// </param>
        /// <returns>True if account is successfully authorized, false otherwise.</returns>
        bool AuthorizeAccount(string userName, UserTypes accountType, ref UserRoles assignedRoles);
    }
}